<?php
namespace app\index\controller;

use think\Controller;
use think\Db;

class Aboutus extends Controller
{
	//医院简介
    public function about_brief()
    {
        $this->types();
        $hospital = Db::table('hospital')->where(array('id'=>1))->find();
        $this->assign('hospital',$hospital);
        return $this->fetch();
    }
    //荣誉资质
    public function about_honnor()
    {
        $this->types();
    	$honnor = Db::table('honnor')->select();
    	$this->assign('honnor',$honnor);
    	return $this->fetch();
    }
    //医师团队
    public function about_team()
    {
        $this->types();
    	//院内医生
    	$lista = Db::table('doctor') -> where(array('status'=>1))->select();
    	//特邀医生
    	$listb = Db::table('doctor') -> where(array('status'=>2))->select();
    	$this->assign('lista',$lista);
    	$this->assign('listb',$listb);
    	return $this->fetch();
    }
    //医师团队医师详情
    public function about_teams()
    {
    	$id = (int)input('get.id');
    	$list = Db::table('doctor')->where(array('id'=>$id))->find();
        $this->assign('list',$list);
    	return $this->fetch();
    }
    //设备材质
    public function about_mater()
    {
        $this->types();
        //进口材料
        $lista = Db::table('equipment')->where(array('status'=>1))->select();
        //国际设备
        $listb = Db::table('equipment')->where(array('status'=>2))->select();
        $this->assign('lista',$lista);
        $this->assign('listb',$listb);
        return $this->fetch();
    }
    //设备材质详情
    public function about_maters()
    {
        $id = (int)input('get.id');
        $list = Db::table('equipment')->where(array('id'=>$id))->find();
        $this->assign('list',$list);
        return $this->fetch();
    }
    //来院路线
    public function about_route()
    {
        $this->types();
        return $this->fetch();
    }
    //地图
    public function about_map()
    {
        return $this->fetch();
    }
    public function types()
    {
        //获取一级分类
        $type = Db::table('type')->where(array('pid'=>0))->select();
        $type2 = array();
        $type3 = array();
        foreach($type as $key=>$value){
            $type[$key]['child']=array();//二级分类的名字
            $type2=Db::table('type')->where("pid=".$value['id'])->select();//获取二级分类

            foreach($type2 as $k=>$v){
                
              

                array_push($type[$key]['child'],$v);//合并一级与二级分类
                $type[$key]['child'][$k]['child2']=array();////三级分类的名字
               
                    $type3=Db::table('type')->where("pid=".$v['id'])->select();//获取三级分类
                    foreach($type3 as $v2){


                          array_push($type[$key]['child'][$k]['child2'],$v2);//合并一级二级三级分类
                    }
                  
               
            }

        }
        $this->assign('type',$type);
    }
}